

import java.util.Timer;

import javax.swing.JPanel;

public class MapController {
	
	public Map map;
	
	private int[][] info;
	private String mode;	
	
	private MapConnector mconn;
	private Timer runner;
 	
	public MapController() {
		map = new Map();
		mconn = new MapConnector(this);
		runner = new Timer();
		mode = "surrounding";
	}
	
	public void init (int[][] __info) {
		this.info = __info;
		int[] position = this.mconn.getMyPostion();
		
		map.init(info);
		map.setMode(mode);
		map.load(position[0], position[1], position[2]);
		
		mconn.set_length(info.length, info[0].length);
	}
	
	public void setMode (String __mode) {
		this.mode = __mode;
	}
	
	public void setFilteringId (int filtering_id) {
		map.filtering(filtering_id);
	}
	
	public JPanel setMap(int x, int y, int width, int height) {
		JPanel __panel = map.setPanel(x, y, width, height);
		
		start();
		
		return __panel;
	}
	
	public void start () {
		int[] position = this.mconn.getMyPostion();
		
		map.load(position[0], position[1], position[2]);
		//map.start();

		// thread ...
		//
		runner.schedule(mconn, 2000, 2000);
	}
}
